package com.wanyang.dao.base;

import com.wanyang.core.page.Pagination;
import org.nutz.dao.Cnd;
import org.nutz.dao.Condition;
import org.nutz.dao.SqlManager;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.SqlCallback;

import java.util.List;
import java.util.Map;

/**
 * Created by Alan on 16/3/7.
 */
public interface CommonDao<T> {
    T fetch(long id);

    T fetch(String name);

    T fetchWith(long id, String obj);

    Object fetch(Class cls, long id);

    Object fetch(Class cls, String name);

    Object create(Object o);

    int update(Object o);

    int delete(Object o);

    Pagination listPage(Integer pageNumber, Condition cnd);

    Pagination listPage(Integer pageNumber, Sql sql);

    Pagination listPage(Integer pageNumber, int limit, Condition cnd);

    Pagination listPage(Integer pageNumber, int limit, Sql sql);

    T queryObject(String sql, Map<String, Object> varMap, Map<String, Object> paramsMap, Class cls);

    List<T> query(Condition cnd);

    List<T> query(String sql, Class cls);

    Integer execute(String sql, Map<String, Object> varMap, Map<String, Object> paramsMap);

    List<T> query(String sql, Map<String, Object> varMap, Map<String, Object> paramsMap);

    List query(String sql, Map<String, Object> varMap, Map<String, Object> paramsMap, Class cls);

    SqlManager sqls();

    Object execute(Sql sql);

    T queryForOne(Cnd cnd);

    Integer updateWithLinks(Object o, String regex);

    Integer createWithLinks(Object o, String regex);

    SqlCallback createSqlCallBack(boolean listOrNot, Class cls);
}
